qui(
    function (require, exports, module) {
        VOD.Dao = $.extend({}, EpgWeb.Dao, {
            cache: {},
            settings: {
                index: 1,
                stime: 0,
                etime: 0,
                pic: 0,
                taskid: 0,
                lastImg: 0,
                delList: [],
                subData: [],
         //       needDatas: [],
                isStart: false,
                isSetFpTime: false,
                lb: 1,
                firstFpTime: 0,
                last_i: 0,   // 上次识的库索引
                adLibList: [],
                isOver: 1,  //防止并发
                fpTime: 'fp_time',

                // page use
                period: '',
                linePicNum: 9,
                today: '',
             //   videonameArr:[],
                g_ocrList:[],
                g_acrList:[],
                reg_last_id: 0
            },
            playOneInfo: {mouseenter: false},
            getParamsData: function () {
                return this.getDataByName("params");
            },
            // 入广告智能库
            saveAdLibrary: function (options, callback) {
                options.from_client = true;  //绕过鉴权
                var url = this.getDotData().smartLibrary;
                $.ajax({
                    cache: false,
                    async: false,
                    type: "post",
                    url: url + 'doad',
                    data: options,
                    success: function (res) {
                        callback.call(this, res);
                    },
                    dataType: "json",
                    error: function () {
                        //alert('网络错误,请稍后再入广告智能库！');
                        VOD.Plugin.tips("error", '网络错误,请稍后再入广告智能库！');
                    }
                });
            },
            // 专辑入智能库
            saveAlbumLibrary: function (options, callback) {
                options.from_client = true;

                var head = options.list.head,
                    end = options.list.end,
                    aHead = options.offset.head,
                    aEnd = options.offset.end;

                options.list = head;
                options.offset = aHead;
                var url = this.getDotData().smartLibrary;
                $.ajax({
                    cache: false,
                    async: false,
                    type: "post",
                    url: url + 'dohead',
                    data: options,
                    success: function (res) {
                        options.list = end;
                        options.offset = aEnd;

                        $.ajax({
                            cache: false,
                            async: false,
                            type: "post",
                            url: url + 'doend',
                            data: options,
                            success: function (res) {
                                callback.call(this, res);
                            },
                            dataType: "json",
                            error: function () {
                                //alert('网络错误,请稍后再入广告智能库！');
                                VOD.Plugin.tips("error", '网络错误,请稍后再入广告智能库！');
                            }
                        });
                    },
                    dataType: "json",
                    error: function () {
                        //alert('网络错误,请稍后再专辑入智能库！');
                        VOD.Plugin.tips("error", '网络错误,请稍后再专辑入智能库！');
                    }
                });
            },

            getDotData: function () {
                return this.getDataByName("dot");
            },
            getDataByName: function (targetName) {
                if (!this.cache.hasOwnProperty(targetName)) {
                    if (this.hasOwnProperty("method_" + targetName)) {
                        var target = this["method_" + targetName]();
                        this.cache[targetName] = target;
                        return target;
                    } else {
                        return null;
                    }
                } else {
                    return this.cache[targetName];
                }
            },
            method_params: function () {
                var queryStringObj = VOD.Util.getUrlParams();
                var obj = {};
                obj["channel_name"] = queryStringObj['channel_code'];
                obj["ip"] = queryStringObj['ip'];
                obj["freeType"] = queryStringObj['free_type'];
                obj["_channel_id"] = queryStringObj['channel_id'];
                obj["_channel_name_str"] = queryStringObj['cn'];
                obj["locationCategory"] = queryStringObj['locationCategory'];
                obj["location"] = queryStringObj['location'];
                obj["startTime"]=queryStringObj['startTime'];
                obj["endTime"]=queryStringObj['endTime'];
                return obj;
            },
            method_dot: function () {
                var params = this.getParamsData();
                var obj = {};
                obj.dotUrl = 'http://' + params.ip + ':8080/dot/dodot';
                obj.adUrl = 'http://' + params.ip + ':8080/dot/doadstore'; // 广告入库学习
                obj.listUrl = 'http://' + params.ip + ':8080/dot/json';
                obj.initUrl = 'http://' + params.ip + ':8080/dot/init';
               // obj.cateUrl = 'http://' + params.ip + ':8080/dot/cate';
                obj.sty2Url = 'http://' + params.ip + ':8080/dot/sty2';//智能分析
                obj.ocrUrl = 'http://' + params.ip + ':8080/dot/ocr';
                obj.acrUrl = 'http://' + params.ip + ':8080/dot/acr';
                obj.channelInfoUrl = 'http://' + params.ip + ':8080/channel/channelinfo';
                obj.analysis = 'http://' + params.ip + ':9090/dot/analysis';
                obj.sty = 'http://' + params.ip + ':8080/dot/sty'; // 自动拆条
                obj.codeVersionUrl = 'http://' + params.ip + ':8080/version'; // 编码器版本号
                obj.smartLibrary = 'http://' + params.ip + ':8080/dot/';
                return obj;
            },
            // 获取合作方信息
            getCooperativePartner : function (options, callback) {
                if (options.channeltype == 'undefined' || options.channelalias == 'undefined' || options.channeltype == '' || options.channelalias == '')
                    return '';
                $.get(VOD.urlConfig.partnerUrl, options, function (res) {
                    if (res.code == 200) {
                        callback.call(this, res.response.data);
                    } else {
                        console.log("【合作方失败信息】" + res.msg);
                    }
                }, 'json');
            },
            getCodeVersion : function (options) {
              var codeVersionUrl =  this.getDotData().codeVersionUrl;
                $.ajax({
                    cache : false,
                    async : false,
                    type : "get",
                    url : codeVersionUrl,
                    data : {
                        'data' : JSON.stringify(options)
                    },
                    success : function (data) {
                        VOD.Dao.storageData('coderVersion', data);
                    },
                    error : function () {
                        console.log('请求编码器版本号失败,请稍后再试！');
                    }
                });
            },
            getChannelType:function(handler){
                var options = {
                    url:  VOD.Constant.thirdUrl_channel,
                    type: "get",
                    data:{size:100},
                    success: function (data) {
                        var formatData = [];
                        $.each(data.data,function(i,element){
                            formatData.push({id:element.id,label:element.name,value:element.name})
                        })
                        handler(formatData);
                        console.log("renderPanel happen");
                    },
                    error:function(data){
                        console.log("error happen");
                    }
                }
                this.sendProxy(options);
            },
            delNews:function(data,callback){
                var url = this.getDotData().sty;
                var options = {
                    type: "post",
                    url: url,
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                $.ajax(options);
            },
            getNewsList:function(data,callback){
                var url = this.getDotData().sty;
                //var url = "http://10.23.70.35:8080/dot/sty"
                this.doGet( url,data,callback );

            },
            // original structure
            storageData: function (name, value) {
                var DSN = $('#storage-data');
                if (!value && !name)
                    return '';
                else if (value == undefined)
                    return DSN.data(name);
                else
                    DSN.data(name, value);
            }
        })
    }
);